package com.mengshu.platform.mapper;

import com.mengshu.mybatisplus.basic.BasicMapper;
import com.mengshu.platform.po.AdminUserPO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface AdminUserMapper extends BasicMapper<AdminUserPO> {

    @Select("select m.permission from admin_menu m, admin_user u, admin_role r, admin_role_menu rm, auto_user_role ur where u.id = ur.user_id and r.id = ur.role_id and r.id = rm.role_id and m.id = rm.menu_id and u.id = #{userId}")
    Set<String> getPermissions(@Param("userId") long userId);

    @Select("select m.permission from admin_menu m, admin_user u, admin_role r, admin_role_menu rm, auto_user_role ur where u.id = ur.user_id and r.id = ur.role_id and r.id = rm.role_id and m.id = rm.menu_id")
    Set<String> listPermissions();
}
